Expand description

FlatGeobuf is a performant binary encoding for geographic data based on flatbuffers that can hold a collection of Simple Features including circular interpolations as defined by SQL-MM Part 3.

Reading a FlatGeobuf file

use flatgeobuf::*;
use geozero::ToJson;

let mut filein = BufReader::new(File::open("countries.fgb")?);
let mut fgb = FgbReader::open(&mut filein)?.select_all()?;
while let Some(feature) = fgb.next()? {
    println!("{}", feature.property::<String>("name").unwrap());
    println!("{}", feature.to_json()?);
}

Zero-copy geometry reader

Geometries can be accessed by implementing the GeomProcessor trait.

use geozero::{GeomProcessor, error::Result};

struct CoordPrinter;

impl GeomProcessor for CoordPrinter {
    fn xy(&mut self, x: f64, y: f64, _idx: usize) -> Result<()> {
        println!("({} {})", x, y);
        Ok(())
    }
}

let mut coord_printer = CoordPrinter {};
feature.process_geom(&mut coord_printer)?;

Reading FlatGeobuf via HTTP

use flatgeobuf::*;
use geozero::ToWkt;

let mut fgb = HttpFgbReader::open("https://!flatgeobuf.org/test/data/countries.fgb")
    .await?
    .select_bbox(8.8, 47.2, 9.5, 55.3)
    .await?;
while let Some(feature) = fgb.next().await? {
    let props = feature.properties()?;
    println!("{}", props["name"]);
    println!("{}", feature.to_wkt()?);
}

Modules

Create and read a packed Hilbert R-Tree to enable fast bounding box spatial filtering.

Structs

Enums

Constants

Traits

A fallible, streaming iterator.

Feature processing API

Feature properties processing API

Geometry processing trait.

Functions

Read FlatGeobuf geometry

Verifies that a buffer of bytes contains a Feature and returns it. Note that verification is still experimental and may not catch every error, or be maximally performant. For the previous, unchecked, behavior use root_as_feature_unchecked.

Assumes, without verification, that a buffer of bytes contains a Feature and returns it.

Verifies, with the given options, that a buffer of bytes contains a Feature and returns it. Note that verification is still experimental and may not catch every error, or be maximally performant. For the previous, unchecked, behavior use root_as_feature_unchecked.

Verifies that a buffer of bytes contains a Header and returns it. Note that verification is still experimental and may not catch every error, or be maximally performant. For the previous, unchecked, behavior use root_as_header_unchecked.

Assumes, without verification, that a buffer of bytes contains a Header and returns it.

Verifies, with the given options, that a buffer of bytes contains a Header and returns it. Note that verification is still experimental and may not catch every error, or be maximally performant. For the previous, unchecked, behavior use root_as_header_unchecked.

Verifies that a buffer of bytes contains a size prefixed Feature and returns it. Note that verification is still experimental and may not catch every error, or be maximally performant. For the previous, unchecked, behavior use size_prefixed_root_as_feature_unchecked.

Assumes, without verification, that a buffer of bytes contains a size prefixed Feature and returns it.

Verifies, with the given verifier options, that a buffer of bytes contains a size prefixed Feature and returns it. Note that verification is still experimental and may not catch every error, or be maximally performant. For the previous, unchecked, behavior use root_as_feature_unchecked.

Verifies that a buffer of bytes contains a size prefixed Header and returns it. Note that verification is still experimental and may not catch every error, or be maximally performant. For the previous, unchecked, behavior use size_prefixed_root_as_header_unchecked.

Assumes, without verification, that a buffer of bytes contains a size prefixed Header and returns it.

Verifies, with the given verifier options, that a buffer of bytes contains a size prefixed Header and returns it. Note that verification is still experimental and may not catch every error, or be maximally performant. For the previous, unchecked, behavior use root_as_header_unchecked.